<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>9-获取子节点</title>
	</head>
	<body>
		<ul>
			<li>百度</li>
			<li>李宝莉</li>
			<li>张端阳</li>
		</ul>
		<script type="text/javascript">
			//语法：父元素对象.childNodes
			var parentNode = document.querySelector('ul');
			//此方法了解
			console.log(parentNode.childNodes);
			console.log(parentNode.childNodes[0].nodeType);//3-\n\t
			console.log(parentNode.childNodes[1].nodeType);//1-element-node
			//HTMLCollection { 0: li, 1: li, 2: li, length: 3 }

			
			console.log(parentNode.firstChild);//#text
			console.log(parentNode.lastChild);//#text
			
			console.log(parentNode.firstElementChild);//ele
			console.log(parentNode.lastElementChild);//ele
			
			//直接用数组写法，熟记
			//只获取元素节点
			console.log(parentNode.children);			
			var onele = parentNode.children[0];
			var lastele = parentNode.children[parentNode.children.length-1];
			
			console.log(onele);
			console.log(lastele);
		</script>
	</body>
</html>
